$(document).ready(function(){
	$("input").keydown(function(event){
		if (event.keyCode == 13){
			$("#login").trigger("click");
		}
	});
	$("#login").click(function(){
		$(".container-status").html('<i class="fa fa-spinner fa-spin fa-lw"></i> 正在登录中……');
		$(".container-status").slideDown('fast');
		$.post('/api/userlogin',
				{
					username: $('#username').val(),
					password: $('#password').val()
				},
				function(data){
					if (data.status == true){
						$(".container-status").html('<span class="success"><i class="fa fa-check fa-lw"></i> 登录成功</span>');
						$(location).attr('href', '/');
					} else {
						$(".container-status").html('<span class="failed"><i class="fa fa-times fa-lw"></i> ' + data.message + '</span>');
					}
				});
	});
});